home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-03-06 | 8.0 KB | 393 lines | [TEXT/MPS ] |
-
- Dear MacApp developers,
-
- In my use of MacApp version 2.0b5 I have run across several bugs/dislikes. Some
- of the problems are serious, so I felt that I should send this in now.
-
- Some of the problems I have found so far are only potential problems, such as the
- under-use of the failure mechanism, but I think they should be addressed system wide.
- You can't assume that methods which may be overridden will never fail. Obviously,
- I hope you agree with my reasoning.
-
- I hope this helps. Let me know if you need any more information.
-
- Gary L. Bringhurst
- Strata
-
-
- ---------
-
- Affected/fixed routines follow:
-
-
-
- PROCEDURE TRadio.DoChoice(origView: TView; itsChoice: INTEGER);
- BEGIN
- (*
- ** Modified to pass on the itsChoice message. The original design decision was wrong,
- ** while the comment was right. Subclasses of TRadio may want the itsChoice message
- ** to travel up the view hierarchy. (mine do)
- ** Changed 11/2/88 by GLB.
- *)
- {$IFC False}
- IF (itsChoice = mRadioHit) & NOT IsOn THEN
- BEGIN
- Toggle(kRedraw);
- INHERITED DoChoice(origView, itsChoice); { Should this be called regardless??? }
- END;
- {$ELSEC}
- IF (itsChoice = mRadioHit) & NOT IsOn THEN
- Toggle(kRedraw);
- INHERITED DoChoice(origView, itsChoice);
- {$ENDC}
- END;
-
-
-
- FUNCTION TCluster.ReportCurrent: IDType;
- VAR
- rView: TView;
-
- {-------------------------------+
- | FindRadio |
- +-------------------------------}
- FUNCTION FindRadio(aView: TView): BOOLEAN;
- BEGIN
- (*
- ** This test MUST be a short-circuit test, in case the view is NOT TRadio!
- ** Modified 11/1/88 by GLB.
- *)
- {$IFC False}
- FindRadio := MEMBER(aView, TRadio) AND TRadio(aView).IsOn;
- {$ELSEC}
- FindRadio := MEMBER(aView, TRadio) & TRadio(aView).IsOn;
- {$ENDC}
- END;
-
- BEGIN
- rView := FirstSubViewThat(FindRadio);
- IF rView <> NIL THEN
- ReportCurrent := rView.fIdentifier
- ELSE
- ReportCurrent := kNoIdentifier;
- END;
-
-
-
- PROCEDURE TPicture.Draw (area: Rect); OVERRIDE;
- VAR
- oldState: SignedByte;
- theRect: Rect;
-
- BEGIN
- IF fDataHandle <> NIL THEN
- BEGIN
- ControlArea(theRect);
- IF fRsrcID <> kNoResource THEN
- LoadResource(Handle(fDataHandle));
- (*
- ** This doesn't make any sense! We know that fDataHandle <> NIL. What we don't know
- ** is if it's empty, even after the (potential) LoadResource call above.
- ** Changed 11/2/88 by GLB.
- *)
- {$IFC False}
- IF fDataHandle = NIL THEN
- {$ELSEC}
- IF fDataHandle^ = NIL THEN
- {$ENDC}
- ReleasePicture { Isn't this a little harsh??? }
- ELSE
- BEGIN
- oldState := GetHandleBits(Handle(fDataHandle));
- HNoPurge(Handle(fDataHandle));
- PenNormal; { ??? NECESSARY ??? }
- DrawPicture(fDataHandle, theRect);
- SetHandleBits(Handle(fDataHandle), oldState);
- END;
- END;
- INHERITED Draw(area);
- END;
-
-
-
- FUNCTION ParseTitleTemplate(VAR template: Str255; VAR preDocname, constTitle: INTEGER): BOOLEAN;
-
- ...
-
- {$IFC False}
- FUNCTION FindPos (pattern: Str255; VAR source: Str255): INTEGER;
- {$ELSEC}
- FUNCTION FindPos (pattern: Str255; source: Str255): INTEGER;
- {$ENDC}
- VAR
- position: INTEGER;
- BEGIN
- (*
- ** What good does this crap do??? It will repeat forever unless some change is
- ** made after CharByte fails! (It also calls even though position = 0)
- *)
- {$IFC False}
- IF gConfiguration.hasScriptManager THEN
- REPEAT
- position := POS(pattern, source);
- UNTIL (position = 0) OR (CharByte(@source, position) = 0)
- {$ELSEC}
- { This bug fix added 11/1/88 by GLB }
- IF gConfiguration.hasScriptManager THEN
- WHILE True DO BEGIN
- position := POS(pattern, source);
- IF (position = 0) | (CharByte(@source, position) = 0) THEN
- Leave;
- REPEAT
- position:= position + 1;
- UNTIL CharByte(@source, position) <= 0;
- Delete(source, 1, position - 1);
- END
- {$ENDC}
- ELSE
- position := POS(pattern, source);
- FindPos := position;
- END;
-
- BEGIN
-
- ...
-
- END;
-
-
-
- FUNCTION TApplication.TrackCursor: BOOLEAN;
-
- ...
-
- BEGIN
-
- ...
-
- IF (FindWindow(globalMouse, aWMgrWindow) = inContent) THEN
- BEGIN
- { The cursor is in a window--for our purposes, it must be the front
- window or the window must handle first clicks }
- cursorWindow := WMgrToWindow(aWMgrWindow);
- (*
- ** BUG! Repaired 10/31/88 by GLB
- *)
- IF {Added} (cursorWindow <> NIL) {Done} &
- (cursorWindow <> gFrontWindow) & (NOT cursorWindow.fDoFirstClick) THEN
- cursorWindow := NIL;
- END
- ELSE
- cursorWindow := NIL;
-
- ...
-
- END;
-
-
-
- PROCEDURE TView.DrawContents;
- VAR
-
- ...
-
- fi: FailInfo;
-
-
- PROCEDURE HdlTVDCFail(error: OSErr; message: Longint);
- BEGIN
- DisposeRgn(savedClip);
- END; { HdlTVDCFail }
-
- ...
-
- BEGIN
- IF Focus THEN
- BEGIN
-
- ...
-
- IF (NOT displaying) | SectRect(visRect, thePort^.visRgn^^.rgnbBox, visRect) THEN
- BEGIN
-
- ...
-
- (*
- ** Please, oh please, use the failure mechanism to ensure that we don't
- ** leave here without disposing of our temporary region!
- ** Changed 11/8/88 by GLB.
- *)
- IF CountSubViews > 0 THEN
- BEGIN
- longOffset := gLongOffset;
- savedClip := MakeNewRgn; { Save the superview's focus. }
-
- { *** } CatchFailures(fi, HdlTVDCFail);
-
- savedOrigin := thePort^.portRect.topLeft;
- savedLongOffset := gLongOffset;
- GetClip(savedClip);
- EachSubView(DrawSubView);
-
- { *** } Success(fi);
-
- DisposeRgn(savedClip);
- END;
- END;
- END;
- END {TView.DrawContents};
-
-
-
- PROCEDURE TView.LocalToWindow (VAR thePoint: VPoint);
-
- VAR
- aView: TView;
-
- BEGIN
- aView := SELF;
- (*
- ** The existing algorithm changes from local to global coordinates.
- ** (if we are actually in a window)
- ** Changed 11/7/88 by GLB.
- *)
- {$IFC False}
- WHILE aView <> NIL DO
- {$ELSEC}
- WHILE aView.fSuperView <> NIL DO
- {$ENDC}
- BEGIN
- AddVPt(aView.fLocation, thePoint);
- aView := aView.fSuperView;
- END;
- END {TView.LocalToWindow};
-
-
-
- PROCEDURE TView.WindowToLocal (VAR thePoint: VPoint);
-
- VAR
- aView: TView;
-
- BEGIN
- aView := SELF;
- (*
- ** The existing algorithm changes from global to local coordinates.
- ** (if we are actually in a window)
- ** Changed 11/7/88 by GLB.
- *)
- {$IFC False}
- WHILE aView <> NIL DO
- {$ELSEC}
- WHILE aView.fSuperView <> NIL DO
- {$ENDC}
- BEGIN
- SubVPt(aView.fLocation, thePoint);
- aView := aView.fSuperView;
- END;
- END {TView.WindowToLocal};
-
-
-
- (*
- ** I didn't mark carefully all of the changes to this method. If you agree with me that
- ** it needs fixing you'll have to do a comparison with the original to find all of my
- ** changes.
- *)
-
- PROCEDURE TView.WriteToDeskScrap;
- VAR
- pHndl: PicHandle;
- picOpen: Boolean;
- qdExtent: Rect;
- err: LONGINT;
- tempPort: GrafPort;
- tempCPort: CGrafPort;
- fi: FailInfo;
-
-
- (*
- ** This method MUST catch any failures in order to ensure nothing is left
- ** dangling!
- ** Fixed 11/5/88 by GLB.
- *)
- PROCEDURE HdlTVWTDSFail(error: OSErr; message: Longint);
- BEGIN
- IF pHndl <> NIL THEN BEGIN
- IF gDrawingPictScrap THEN BEGIN
- ClosePicture;
- gDrawingPictScrap:= False;
- END;
- KillPicture(pHndl);
- END;
- IF gConfiguration.hasColorQD THEN
- CloseCPort(@tempCPort)
- ELSE
- ClosePort(@tempPort);
- END; { HdlTVWTDSFail }
-
-
- BEGIN
- GetQDExtent(qdExtent);
-
- IF gConfiguration.hasColorQD THEN
- OpenCPort(@tempCPort)
- ELSE
- OpenPort(@tempPort);
-
- {Open color or black & white, depending on the port}
- pHndl := OpenPicture(qdExtent);
-
- CatchFailures(fi, HdlTVWTDSFail);
-
- IF pHndl <> NIL THEN
- BEGIN
- gDrawingPictScrap := TRUE;
- ClipRect(qdExtent);
-
- Draw(qdExtent);
-
- gDrawingPictScrap := FALSE;
- ClosePicture;
-
- {On the 128K ROMs the picFrame will be empty if drawing the
- picture failed. On the 64K ROM's QuickDraw simply bombs.}
- IF EmptyRect(pHndl^^.picFrame) THEN
- BEGIN
- {$IFC qDebug}
- WRITELN('Picture frame is empty!');
- {$ENDC}
- KillPicture(pHndl);
- pHndl:= NIL;
- Failure(memFullErr, 0);
- END;
-
- err := PutDeskScrapData('PICT', Handle(pHndl));
- KillPicture(pHndl);
- pHndl:= NIL;
-
- IF err <> NoErr THEN
- BEGIN
- {$IFC qDebug}
- ProgramBreak('Failed to put PICT-type scrap');
- {$ENDC}
- Failure(err, 0);
- END;
- END
- ELSE
- BEGIN
- {$IFC qDebug}
- ProgramBreak('Couldn''t 0penPicture during attempt to write PICT to desk scrap');
- {$ENDC}
- Failure(memFullErr, 0); {Assume cause of failure was lack of memory}
- END;
-
- Success(fi);
-
- IF gConfiguration.hasColorQD THEN
- CloseCPort(@tempCPort)
- ELSE
- ClosePort(@tempPort);
- END {TView.WriteToDeskScrap};
-
-